/**
 * Created by Administrator on 2018/11/16.
 */
new Vue({
    el:'.container',
    data:{
        addressList:[],
        numLimit:3,
        currentIndex:0,
        shipping:1,
        showFlag:false,
        listIndex:''
    },
    mounted:function () {
        this.$nextTick(function () {
            this.addressView()
        })
    },
    computed:{
        filterAddress:function () {
            return this.addressList.slice(0,this.numLimit)
        }
    },

    methods:{
        addressView:function () {
            this.$http.get("../data/address.json",{}).then(res=>{
                this.addressList=res.data.result
            })
        },
        loadMore:function () {
            this.numLimit+=4
        },
        setDefault:function (addressId) {
            this.addressList.forEach((item,index)=>{
                if(item.addressId==addressId){
                    item.isDefault=true;
                }else{
                    item.isDefault=false;
                }
            })
        },
        delList:function (item) {
            this.showFlag=true;
            this.listIndex=item;
            console.log(this.listIndex);

        },
        delRemove:function () {
            var index=this.addressList.indexOf(this.listIndex)
            console.log(index);
            this.addressList.splice(index,1);
            this.showFlag=false;
        }

    }
});
